package com.ruoyi.fun.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fun.mapper.EcProductCommentMapper;
import com.ruoyi.fun.domain.EcProductComment;
import com.ruoyi.fun.service.IEcProductCommentService;

/**
 * 商品评价Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-06
 */
@Service
public class EcProductCommentServiceImpl implements IEcProductCommentService 
{
    @Autowired
    private EcProductCommentMapper ecProductCommentMapper;

    /**
     * 查询商品评价
     * 
     * @param commentId 商品评价主键
     * @return 商品评价
     */
    @Override
    public EcProductComment selectEcProductCommentByCommentId(Long commentId)
    {
        return ecProductCommentMapper.selectEcProductCommentByCommentId(commentId);
    }

    /**
     * 查询商品评价列表
     * 
     * @param ecProductComment 商品评价
     * @return 商品评价
     */
    @Override
    public List<EcProductComment> selectEcProductCommentList(EcProductComment ecProductComment)
    {
        System.out.println("[DEBUG] EcProductCommentServiceImpl.selectEcProductCommentList - 查询参数 orgId: " + ecProductComment.getOrgId());
        List<EcProductComment> result = ecProductCommentMapper.selectEcProductCommentList(ecProductComment);
        System.out.println("[DEBUG] EcProductCommentServiceImpl.selectEcProductCommentList - 查询结果数量: " + result.size());
        for (EcProductComment comment : result) {
            System.out.println("[DEBUG] EcProductCommentServiceImpl.selectEcProductCommentList - 评价ID: " + comment.getCommentId() + ", orgId: " + comment.getOrgId());
        }
        return result;
    }

    /**
     * 新增商品评价
     * 
     * @param ecProductComment 商品评价
     * @return 结果
     */
    @Override
    public int insertEcProductComment(EcProductComment ecProductComment)
    {
        ecProductComment.setCreateTime(DateUtils.getNowDate());
        ecProductComment.setOrgId(SecurityUtils.getDeptId());
        return ecProductCommentMapper.insertEcProductComment(ecProductComment);
    }

    /**
     * 修改商品评价
     * 
     * @param ecProductComment 商品评价
     * @return 结果
     */
    @Override
    public int updateEcProductComment(EcProductComment ecProductComment)
    {
        ecProductComment.setUpdateTime(DateUtils.getNowDate());
        return ecProductCommentMapper.updateEcProductComment(ecProductComment);
    }

    /**
     * 批量删除商品评价
     * 
     * @param commentIds 需要删除的商品评价主键
     * @return 结果
     */
    @Override
    public int deleteEcProductCommentByCommentIds(Long[] commentIds)
    {
        return ecProductCommentMapper.deleteEcProductCommentByCommentIds(commentIds);
    }

    /**
     * 删除商品评价信息
     * 
     * @param commentId 商品评价主键
     * @return 结果
     */
    @Override
    public int deleteEcProductCommentByCommentId(Long commentId)
    {
        return ecProductCommentMapper.deleteEcProductCommentByCommentId(commentId);
    }

    /**
     * 根据commentId和组织ID查询ProductComment
     * 
     * @param commentId ProductComment主键
     * @param orgId 组织ID
     * @return ProductComment
     */
    @Override
    public EcProductComment selectEcProductCommentByCommentIdAndOrgId(Long commentId, Long orgId)
    {
        return ecProductCommentMapper.selectEcProductCommentByCommentIdAndOrgId(commentId, orgId);
    }

    /**
     * 根据组织ID查询ProductComment列表
     * 
     * @param ecproductcomment ProductComment
     * @param orgId 组织ID
     * @return ProductComment集合
     */
    @Override
    public List<EcProductComment> selectEcProductCommentListByOrgId(EcProductComment ecproductcomment, Long orgId)
    {
        return ecProductCommentMapper.selectEcProductCommentListByOrgId(ecproductcomment, orgId);
    }
}